/**
 * 详情对话框
 */
var AgvAreaQuotaInfoDlg = {
    data: {
        warehouseId: "",
        warehouseName: "",
        areaName: "",
        agvPauseZone: "",
        agvQuota: "",
        agvNum: "",
        createTime: "",
        updateTime: "",
        createUser: "",
        updateUser: "",
        deptId: "",
        remark: ""
    }
};

layui.use(['form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/agvAreaQuota/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    form.val('agvAreaQuotaForm', result.data);

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/agvAreaQuota/editItem", function (data) {
            Feng.success("更新成功！");
            window.location.href = Feng.ctxPath + '/agvAreaQuota'
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    // 查询库区
    form.on('select(warehouseId)',function(){
        $("#areaName").empty();
        $.ajax({
            url:Feng.ctxPath + '/basicArea/Querylist',
            dataType:"json",   //返回格式为json
            async: false,
            data:{"areaWarehouseId":$("#warehouseId").val()},    //参数值
            type:"post",   //请求方式
            success:function(data){
                if(data.length>0){
                    var str = "<option value=''>请选择</option>";
                    $.each(data,function(key,value){
                        str += "<option value='"+value.areaName+"'>"+value.areaName+"</option>";
                    });
                    $("#areaName").html(str);
                }
            }
        });
        form.render('select');
    });

    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + '/agvAreaQuota'
    });

});